home *** CD-ROM | disk | FTP | other *** search
- /*
- * Object.c
- *
- * Robert Dierkes, November 11, 1993
- *
- * Change History:
- *
- * 11/93 ??? New
- * 4/96 bob Updated #includes to support changed GX Library names.
- * Changed boolean to Boolean.
- * Added the copyright info.
- *
- *
- * © Apple Computer, Inc. 1990 - 1996 All rights reserved
- *
- */
-
- #include <GXGraphics.h>
- #include "GraphicsLibraries.h"
-
- #include "ViewPorts.h"
- #include "Main.h"
- #include "Object.h"
-
-
- /*----------------------*/
- /* Global Declarations */
- /*----------------------*/
- gxPoint gDistance;
- gxColor gBackgroundColor;
-
- /*------------------------------*/
- /* External Declarations */
- /*------------------------------*/
- extern WindowPtr gWindow;
- extern gxShape gFrame,
- gObject,
- gLastObject;
-
-
-
- void SetSimpleColor (gxColor *pColor, commonColor someColor);
- void SetSimpleColor (gxColor *pColor, commonColor someColor)
- {
- pColor->element.indexed.set = commonColorSet;
- pColor->element.indexed.index = someColor;
- pColor->space = gxIndexedSpace;
- pColor->profile = nil;
- pColor->element.rgb.red =
- pColor->element.rgb.red =
- pColor->element.rgb.red = 0xFFFF;
- }
-
-
- /*
- * Global:
- * gDistance
- */
- void
- InitializeObject (Boolean isSquare, Fixed width, Fixed height, gxShape *pObject, gxShape *pLastObject)
- {
- gxRectangle bounds;
-
- if (pObject == nil)
- {
- DebugStr ("\pInitializeObject: pObject is nil");
- return;
- }
-
- DisposeShapeAt (pObject);
-
- bounds.left =
- bounds.top = 0;
- bounds.right = width;
- bounds.bottom = height;
-
- *pObject = isSquare ? GXNewRectangle (&bounds) : NewOval (&bounds);
-
- GXMoveShapeTo (*pObject, fixed1, fixed1);
- SetShapeCommonColor (*pObject, lamp_black);
-
- DisposeShapeAt (pLastObject);
- *pLastObject = GXNewShape (gxEmptyType);
- SetSimpleColor (&gBackgroundColor, gxWhite);
-
- gDistance.x = width >> 3;
- gDistance.y = height >> 3;
- }
-
-
- /*
- * Globals:
- * gDistance
- * gObject
- * gLastObject
- */
- void
- MoveObject (void)
- {
- gxRectangle bounds;
-
- GXGetShapeBounds (gObject, 0, &bounds);
-
- /* Change direction if object reaches window edge */
- if (bounds.left <= 0 ||
- bounds.right >= IntToFixed (gWindow->portRect.right))
- {
- gDistance.x = - gDistance.x;
- }
-
- if (bounds.top <= 0 ||
- bounds.bottom >= IntToFixed (gWindow->portRect.bottom))
- {
- gDistance.y = - gDistance.y;
- }
-
- GXDisposeShape (gLastObject);
- gLastObject = CopyShape (gObject);
- GXSetShapeColor (gLastObject, &gBackgroundColor);
-
- /* Move and draw new object */
- GXMoveShape (gObject, gDistance.x, gDistance.y);
-
- /* Erase portion of previous object */
- GXDifferenceShape (gLastObject, gObject);
- GXDrawShape (gLastObject);
-
- GXDrawShape (gObject);
- }
-
-
- void
- DrawObject (void)
- {
- GXDrawShape (gObject);
- }
-
-
- void
- DrawObjectFrame (void)
- {
- GXDrawShape (gFrame);
- }
-